# -*- encoding=utf8 -*-
"""
RedFlag-TC000028    翻转功能检查
检查相机翻转功能
切换前后置摄像头
"""
__author__ = "ldm"

import sys
import os
# 获取当前脚本所在目录.py
current_dir = os.path.dirname(os.path.abspath(__file__))
# 获取上级目录.air
parent_dir = os.path.dirname(current_dir)
# 获取上级目录air
grandparent_dir = os.path.dirname(parent_dir)
# 获取和air目录平级的conf、testcase目录路径
conf_dir = os.path.join(grandparent_dir, 'conf')
testcase_dir = os.path.join(grandparent_dir, 'testcase')
# 将conf、testcase目录添加到sys.path
sys.path.append(conf_dir)
sys.path.append(testcase_dir)

from PageFunction import CameraVideoShooter
from elements import *
auto_setup(__file__)

shooter = CameraVideoShooter()

log("-----------------获取当前摄像头并转切换到后置摄像头（前置）---------------------")
shooter.enter_photograph()
if not shooting_page_flashlight_elenment.exists():
    shooting_page_rollover_Button.click()

log("----------------------------切换到前置摄像头-------------------------------")
"""
点击切换摄像头
断言（切换后处于前置）
"""
shooter.click_element(shooting_page_rollover_Button)
shooter.assert_image_not_exists(r"tpl1745511421564.png", "断言失败，前置摄像头捕捉到闪光灯图标")

log("-----------------------------切换回后置摄像头---------------------------")
"""
点击切换摄像头
断言（切换后处于后置）
"""
shooter.click_element(shooting_page_rollover_Button)
shooter.assert_image_exists(r"tpl1745511421564.png", "断言失败，后置摄像头并未捕捉到闪光灯图标")

# 关闭应用
stop_app(UGC_package_name)